<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/10/7
  Time: 11:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <%@include file="../../common/header.jsp"%>
    <link rel="stylesheet" type="text/css" href="../../assets/css/reset.css">
    <link rel="stylesheet" type="text/css" href="../../assets/css/css.css">
    <%@include file="../../common/ruoyi.jsp"%>
    <title>排课管理</title>
    <style>
        #kebiao th{
            width: 220px;
            height:100px;
            color: #000;
            border: 0.5px solid black;
            text-align: center;
        }
        #kebiao td{
            border: 0.5px solid black;
            height: 100px;
            text-align: center;
            line-height: 100px;
        }
        #kebiao div{
            font-size: 15px;
            height: 50px;
            line-height: 50px;
            color: red;
            overflow: hidden;
        }
    </style>
    <script>

        var layer;
        $(function () {
            layui.use('layer',function () {
                layer=layui.layer;
            });
        });
        //查询部门信息
        function query() {
            $.ajax({
                url:"${pageContext.request.contextPath}/paike.action?method=query",
                type:"get",
                dataType:"json",
                success:function (data) {
                    $("#tbdata").empty();
                    for (var i = 0; i < data.length; i++) {
                        if (data[i].dayweek=="星期一"&&data[i].shiduan=="8:00-10:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                                "</div>";
                            $("#xianshi1").append(div);
                        }
                        if (data[i].dayweek=="星期二"&&data[i].shiduan=="8:00-10:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi2").append(div);
                        }
                        if (data[i].dayweek=="星期三"&&data[i].shiduan=="8:00-10:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi3").append(div);
                        }
                        if (data[i].dayweek=="星期四"&&data[i].shiduan=="8:00-10:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi4").append(div);
                        }
                        if (data[i].dayweek=="星期五"&&data[i].shiduan=="8:00-10:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi5").append(div);
                        }




                        if (data[i].dayweek=="星期一"&&data[i].shiduan=="10:00-12:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi6").append(div);
                        }
                        if (data[i].dayweek=="星期二"&&data[i].shiduan=="10:00-12:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi7").append(div);
                        }
                        if (data[i].dayweek=="星期三"&&data[i].shiduan=="10:00-12:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi8").append(div);
                        }
                        if (data[i].dayweek=="星期四"&&data[i].shiduan=="10:00-12:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi9").append(div);
                        }
                        if (data[i].dayweek=="星期五"&&data[i].shiduan=="10:00-12:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi10").append(div);
                        }



                        if (data[i].dayweek=="星期一"&&data[i].shiduan=="14:00-15:30") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi11").append(div);
                        }
                        if (data[i].dayweek=="星期二"&&data[i].shiduan=="14:00-15:30") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi12").append(div);
                        }
                        if (data[i].dayweek=="星期三"&&data[i].shiduan=="14:00-15:30") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi13").append(div);
                        }
                        if (data[i].dayweek=="星期四"&&data[i].shiduan=="14:00-15:30") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi14").append(div);
                        }
                        if (data[i].dayweek=="星期五"&&data[i].shiduan=="14:00-15:30") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi15").append(div);
                        }



                        if (data[i].dayweek=="星期一"&&data[i].shiduan=="15:40-17:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi16").append(div);
                        }
                        if (data[i].dayweek=="星期二"&&data[i].shiduan=="15:40-17:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi17").append(div);
                        }
                        if (data[i].dayweek=="星期三"&&data[i].shiduan=="15:40-17:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi18").append(div);
                        }
                        if (data[i].dayweek=="星期四"&&data[i].shiduan=="15:40-17:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi19").append(div);
                        }
                        if (data[i].dayweek=="星期五"&&data[i].shiduan=="15:40-17:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi20").append(div);
                        }



                        if (data[i].dayweek=="星期一"&&data[i].shiduan=="19:00-21:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi21").append(div);
                        }
                        if (data[i].dayweek=="星期二"&&data[i].shiduan=="19:00-21:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi22").append(div);
                        }
                        if (data[i].dayweek=="星期三"&&data[i].shiduan=="19:00-21:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi23").append(div);
                        }
                        if (data[i].dayweek=="星期四"&&data[i].shiduan=="19:00-21:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi24").append(div);
                        }
                        if (data[i].dayweek=="星期五"&&data[i].shiduan=="19:00-21:00") {
                            var div = "<div>"  +""+data[i].classname +""+data[i].keshi + "课时"+data[i].teacher +""+data[i].classroom
                            "</div>";
                            $("#xianshi25").append(div);
                        }

                    }
                },error:function(e){
                    alert(e);
                }
            });
        }
        function paike() {
            $.ajax({
                type:'post',
                url:"${pageContext.request.contextPath}/paike.action?method=add",
                data:$("#paike-form").serialize(),
                dataType:'json',
                success:function(msg)
                {
                    layer.msg("添加成功");
                }
            });
        }

        //绑定老师
        function bindteacher() {
            $.ajax({
                url:"${pageContext.request.contextPath}/paike.action?method=bindteacher",
                type:"get",
                dataType:"json",
                success:function(data){
                    $.each(data,function (i,e) {
                        $("#teacher").append("<option value="+e.user_name+">"+e.user_name+"</option>");
                    })
                },
                error:function (x,t,e) {
                    alert("ERROR:"+t+e);
                }
            });
        }

        //绑定班级
        function bindclass() {
            $.ajax({
                url:"${pageContext.request.contextPath}/paike.action?method=bindclass",
                type:"get",
                dataType:"json",
                success:function(data){
                    $.each(data,function (i,e) {
                        $("#class").append("<option value="+e.classid+">"+e.classname+"</option>");
                    })
                },
                error:function (x,t,e) {
                    alert("ERROR:"+t+e);
                }
            });
        }

        //绑定教室
        function bindroom() {
            $.ajax({
                url:"${pageContext.request.contextPath}/paike.action?method=bindroom",
                type:"get",
                dataType:"json",
                success:function(data){
                    $.each(data,function (i,e) {
                        $("#classroom").append("<option value="+e.room_name+">"+e.room_name+"</option>");
                    })
                },
                error:function (x,t,e) {
                    alert("ERROR:"+t+e);
                }
            });
        }

        $(function(){
            bindclass();
            bindroom();
            bindteacher();
            query();
        });
    </script>

</head>

<script type="text/html" id="op">
    <div class="hidden-sm hidden-xs action-buttons">
        <a class="green" href="#" data-toggle="modal" data-target="#myModal" onclick="updateone({pid})">
            <i class="ace-icon fa fa-pencil "  ></i>编辑
        </a>
        <a class="red" href="#" onclick="deleteuser({sid})">
            <i class="ace-icon fa fa-trash-o "></i>删除
        </a>
    </div>
</script>
<body>


<div class="container-div" >
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="paike-form">
                <div class="select-list">
                    <ul>
                        <li>
                            班级名称：
                            <select name="classid" id="class" type="text"   ></select>
                        </li>
                        <li>
                            上课时间：<select name="shiduan" multiple >
                            <option value="8:00-10:00">8:00-10:00</option>
                            <option value="10:00-12:00">10:00-12:00</option>
                            <option value="14:00-15:30">14:00-15:30</option>
                            <option value="15:40-17:00">15:40-17:00</option>
                            <option value="19:00-21:00">19:00-21:00</option>
                        </select>
                        </li>
                        <li>
                            上课课时：<input type="text" name="keshi"/>
                        </li>
                        <%--<li>--%>
                            <%--上课教室：<select name="classroom" id="classroom" type="text" ></select>--%>
                        <%--</li>--%>
                        <li>
                            上课老师：<select name="teacher" id="teacher" type="text" ></select>
                        </li>
                        <li>
                            上课日期：<select name="dayweek" multiple>
                            <option value="星期一">星期一</option>
                            <option value="星期二">星期二</option>
                            <option value="星期三">星期三</option>
                            <option value="星期四">星期四</option>
                            <option value="星期五">星期五</option>
                        </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="paike()"><i class="fa fa-search"></i>添加课程</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <%--<!--日历-->--%>
            <%--<div style="width: 1200px;height: 342px;margin: 30px auto;" id="rili">--%>
            <%--<div id='calendar'></div>--%>
            <%--</div>--%>
            <table id="kebiao">
                <thead>
                    <th></th>
                    <th>星期一</th>
                    <th>星期二</th>
                    <th>星期三</th>
                    <th>星期四</th>
                    <th>星期五</th>
                </thead>
                <tbody id="tb_paike">
                    <tr>
                        <td>8:00-10:00</td>
                        <td id="xianshi1"></td>
                        <td id="xianshi2"></td>
                        <td id="xianshi3"></td>
                        <td id="xianshi4"></td>
                        <td id="xianshi5"></td>

                    </tr>
                    <tr>
                        <td>10:00-12:00</td>
                        <td id="xianshi6"></td>
                        <td id="xianshi7"></td>
                        <td id="xianshi8"></td>
                        <td id="xianshi9"></td>
                        <td id="xianshi10"></td>

                    </tr>
                    <tr>
                        <td>14:00-15:30</td>
                        <td id="xianshi11"></td>
                        <td id="xianshi12"></td>
                        <td id="xianshi13"></td>
                        <td id="xianshi14"></td>
                        <td id="xianshi15"></td>

                    </tr>
                    <tr>
                        <td>15:40-17:00</td>
                        <td id="xianshi16"></td>
                        <td id="xianshi17"></td>
                        <td id="xianshi18"></td>
                        <td id="xianshi19"></td>
                        <td id="xianshi20"></td>

                    </tr>
                    <tr>
                        <td>19:00-21:00</td>
                        <td id="xianshi21"></td>
                        <td id="xianshi22"></td>
                        <td id="xianshi23"></td>
                        <td id="xianshi24"></td>
                        <td id="xianshi25"></td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>


<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    模态框（Modal）标题
                </h4>
            </div>
            <div class="modal-body">



            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
                <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="paike()">
                   添加课程
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<script type="text/javascript" src="../../assets/js/index.js" ></script>
</body>
</html>
